package cn.hznc.utils.factory;

import cn.hznc.domain.request.program.ExportSubprogramListReq;
import cn.hznc.domain.request.schedule.ExportUnmetToolList;
import cn.hznc.vo.OrderForecastReportExport;
import cn.hznc.vo.ToolUsageReportExport;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;

/**
 * @Author：Administrator
 * @Date：2024/1/4 14:14
 */
public class ExcelExportContext{

    private ExcelExportStrategy excelExportStrategy;

    public ExcelExportContext(){
    }

    public ExcelExportContext(ExcelExportStrategy excelExportStrategy){
        this.excelExportStrategy = excelExportStrategy;
    }

    public <T> ExcelWriter buildExcelWriterByStrategy(T t , ExcelWriter excelWriter , FillConfig fillConfig , WriteSheet writeSheet){
        //ExcelExportContext excelExportContext = new ExcelExportContext((ToolUsageReportExport)t);
        if(t instanceof ToolUsageReportExport){
            ExcelExportContext excelExportContext = new ExcelExportContext((ToolUsageReportExport)t);
            return excelExportContext.buildExcelWriter(excelWriter , fillConfig , writeSheet);
        }else if(t instanceof OrderForecastReportExport){
            ExcelExportContext excelExportContext = new ExcelExportContext((OrderForecastReportExport)t);
            return excelExportContext.buildExcelWriter(excelWriter , fillConfig , writeSheet);
        }else if(t instanceof ExportSubprogramListReq){
            ExcelExportContext excelExportContext = new ExcelExportContext((ExportSubprogramListReq)t);
            return excelExportContext.buildExcelWriter(excelWriter , fillConfig , writeSheet);
        }else if(t instanceof ExportUnmetToolList){
            ExcelExportContext excelExportContext = new ExcelExportContext((ExportUnmetToolList)t);
            return excelExportContext.buildExcelWriter(excelWriter , fillConfig , writeSheet);
        }
        return excelWriter;
    }

    public ExcelWriter buildExcelWriter(ExcelWriter excelWriter , FillConfig fillConfig , WriteSheet writeSheet){
        return excelExportStrategy.buildExcelWrite(excelWriter , fillConfig , writeSheet);
    }
}
